<template>
	<view class="page">
		<view class="deposit-top">
			<view class="">提现至</view>
			<view class="deposit-weixin">
				<image src="/static/imgas/order_wx_pay.png" mode=""></image>
				微信零钱
			</view>
		</view>
		<view class="deposit-box">
			提现金额
			<view class="deposit-small">
				<view class="">￥</view>
				<input type="number" placeholder="请输入提现金额" v-model="price">
				<view class="deposit-all" @tap="allTi">全部提现</view>
			</view>
			<view class="deposit-price">可提现金额￥{{platform_rewards}}</view>
		</view>
		<view class="btn" @tap="sure">确认提现</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				price: '',
				platform_rewards: 0,
				flag: false
			}
		},
		onLoad(options) {
			this.platform_rewards = options.platform_rewards - 0
		},
		onShow() {
			
		},
		methods:{
			allTi(){
				this.price = this.platform_rewards
			},
			sure(){
				if(this.flag){
					return
				}
				if(!this.platform_rewards){
					uni.showToast({
						title: '可提现金额不足',
						icon:'none'
					})
					return
				}
				if(this.price<1){
					uni.showToast({
						title: '提现金额不得低于1元',
						icon:'none'
					})
					return
				}
				if(this.platform_rewards<this.price){
					uni.showToast({
						title: '超出可提现金额，请重新输入',
						icon:'none'
					})
					return
				}
				const params = {
					price: this.price,
					applytype: 1
				}
				this.flag = true
				this.$http.post('/index/Cleanerindex/cleaner_withdrawal_order', params).then(res => {
					uni.showToast({
						title:"申请成功"
					})
					setTimeout(function(){
						uni.navigateBack(1)
					},1000)
				}).catch(res => {
					this.flag = false
					uni.showToast({
						title: res.errMsg,
						icon: "none"
					})
				})
			}
		}
	}
</script>

<style lang="less">
	.page{
		background-color: #f5f5f5;
		height: 100vh;
	}
	.deposit-top{
		height: 120rpx;
		background-color: #fff;
		line-height: 120rpx;
		color: #000000;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
		margin: 16rpx 0;
		.deposit-weixin{
			text-align: right;
			image{
				width: 40rpx;
				height: 34rpx;
				margin-right: 20rpx;
			}
		}
	}
	.deposit-box{
		padding: 40rpx 30rpx;
		background-color: #fff;
		font-size: 28rpx;
		.deposit-small{
			margin-top: 20rpx;
			height: 120rpx;
			line-height: 120rpx;
			display: flex;
			justify-content: space-between;
			font-size: 30rpx;
			color: #1F2129;
			input{
				width: 400rpx;
				height: 100%;
				font-size: 40rpx;
			}
		}
		.deposit-all{
			flex: 1;
			text-align: center;
			color: #FC696F;
			font-size: 30rpx;
		}
	}
	.deposit-price{
		font-size: 24rpx;
		color: #A5A5A9;
		border-top: 2rpx solid #EAEAE9;
		padding-top: 28rpx;
	}
	.btn{
		width: 690rpx;
		margin: 80rpx auto;
		height: 96rpx;
		line-height: 96rpx;
		text-align: center;
		font-size: 36rpx;
		color: #fff;
		border-radius: 96rpx;
		background: linear-gradient(to right,#FF934C,#FC686F);
	}
</style>